const faker = require('faker');

faker.locale = 'zh_CN';

const productSelect = [{ value: 0, name: 'C590' }, { value: 1, name: 'C580' }, { value: 2, name: 'P380' }, { value: 3, name: 'PET-CT 660' }];
const statusSelect = [{ value: 0, name: '新建' }, { value: 1, name: '已发布' }];
const riskStatusSelect = [{ value: 0, name: '新建' }, { value: 1, name: '待评审' }, { value: 2, name: '已评审' }, { value: 3, name: '已发布' }];
const levelSelect = [{ value: 0, name: 'SFS' }, { value: 1, name: 'RS' }, { value: 2, name: 'DS' }];
const moduleSelect = [{ value: 0, name: '信号处理' }, { value: 1, name: '图像重建' }];
const creatorSelect = [{ value: 0, name: '王晓天' }, { value: 1, name: '董京国' }];

// 树数据
const treeData = [{
  id: '1',
  name: '个人',
  children: [{
    id: '1-1',
    name: '文件夹A',
    children: [{
      id: '1-1-1',
      name: '子类A1'
    }, {
      id: '1-1-2',
      name: '子类A2'
    }]
  }, {
    id: '1-4',
    name: '文件夹B',
    children: [{
      id: '1-4-1',
      name: '子类B1'
    }, {
      id: '1-4-2',
      name: '子类B2'
    }]
  }]
}, {
  id: '2',
  name: '团队',
  children: [{
    id: '2-1',
    name: '团队文件夹A',
    children: [{
      id: '2-2-1',
      name: '子类A1'
    }, {
      id: '2-2-2',
      name: '子类A2'
    }]
  }]
}];

// 需求列表
const needList = [];
for (let i = 0; i < 20; i++) {
  needList.push({
    id: faker.random.uuid(),
    title: faker.name.title(),
    status: faker.random.number(1),
    priority: faker.random.number(3),
    level: faker.random.number(2),
    tag: faker.name.jobType(),
    module: faker.random.number(1),
    createTime: Date.now(),
    creator: faker.random.number(1),
  });
}

// 测试列表
const testList = [];
for (let i = 0; i < 20; i++) {
  testList.push({
    id: faker.random.uuid(),
    title: faker.name.title(),
    status: faker.random.number(1),
    level: faker.random.number(2),
    executor: faker.name.lastName(),
    testTime: Date.now(),
    testResult: faker.random.number(1),
    updateTime: Date.now(),
    creator: faker.random.number(1),
  });
}

// 缺陷列表
const defectList = [];
for (let i = 0; i < 20; i++) {
  defectList.push({
    id: faker.random.uuid(),
    title: faker.name.title(),
    status: faker.random.number(1),
    designator: faker.name.lastName(),
    module: faker.random.number(1),
    updateTime: Date.now(),
    createTime: Date.now(),
    creator: faker.random.number(1),
  });
}

// 风险列表
const riskList = [];
for (let i = 0; i < 16; i++) {
  riskList.push({
    id: faker.random.uuid(),
    tag: faker.name.title(),
    feature: faker.name.suffix(),
    harm: faker.name.lastName(),
    expected: faker.name.findName(),
    dangerous: faker.name.suffix(),
    damage: faker.name.suffix(),
    effect: faker.random.word(),
    prevSeverity: faker.name.jobType(),
    prevProbability: faker.name.lastName(),
    prevRange: faker.name.lastName(),
    measureType: faker.name.lastName(),
    riskReqId: faker.random.uuid(),
    measure: faker.name.suffix(),
    laveSeverity: faker.name.suffix(),
    laveProbability: faker.name.suffix(),
    laveRange: faker.name.suffix(),
    module: moduleSelect[Math.floor(Math.random() * moduleSelect.length)].name,
    status: riskStatusSelect[Math.floor(Math.random() * riskStatusSelect.length)].name
  });
}

const columnList = [
  { prop: 'id', label: 'RISK ID' },
  { prop: 'tag', label: '标签' },
  { prop: 'feature', label: '功能' },
  { prop: 'harm', label: '危害' },
  { prop: 'expected', label: '可预见的事件序列' },
  { prop: 'dangerous', label: '危险处境' },
  { prop: 'damage', label: '可能引起的损害' },
  { prop: 'effect', label: '影响' },
  { prop: 'prevSeverity', label: '实施措施之前严重程度' },
  { prop: 'prevProbability', label: '实施措施之前出现概率' },
  { prop: 'prevRange', label: '实施措施之前风险范围' },
  { prop: 'measureType', label: '措施类型' },
  { prop: 'riskReqId', label: '风险需求ID' },
  { prop: 'measure', label: '措施' },
  { prop: 'laveSeverity', label: '剩余风险评估严重程度' },
  { prop: 'laveProbability', label: '剩余风险评估出现概率' },
  { prop: 'laveRange', label: '剩余风险评估风险范围' },
  { prop: 'module', label: '下分模块' },
  { prop: 'status', label: '状态' }
];

// 产品列表
const productList = [];
for (let i = 0; i < 6; i++) {
  productList.push({
    id: i,
    name: `C0CX${i}`
  });
}

// 产品详情
const productDetail = [
  { name: '产品名称', value: 'CT 750' },
  { name: '产品型号', value: '750' },
  { name: '代号', value: 'xyz' },
  { name: '所属项目', value: 'VVV' },
  { name: '产品线', value: 'zzz' },
  { name: '产品描述', value: '这是一个非常好的产品，质量杠杠滴，在下刘德刚，非常佩服这个产品的创意和功用' },
  { name: '产品负责人', value: '王小明' },
  { name: '项目负责人', value: '李晓红' },
  { name: '质量负责人', value: '张晓鹏' },
  { name: '建立时间', value: '2016-02-13' },
  { name: '关闭时间', value: '2017-12-13' },
  { name: '备注', value: null }
];

// 产品层级
const productLevels = [];
for (let i = 0; i < 4; i++) {
  productLevels.push({
    level: i,
    needLevel: `需求层级${i}`,
    testLevel: `测试层级${i}`
  });
}

// 产品状态
const productStatus = [];
const statusNames = ['需求', '测试用例', '测试结果', '风险'];
for (let i = 0; i < statusNames.length; i++) {
  const item = {
    name: statusNames[i],
    children: []
  };
  for (let j = 0; j < 2; j++) {
    const child = {
      name: `${statusNames[i]}层级${j}`,
      value: faker.random.number(1)
    };
    item.children.push(child);
  }
  productStatus.push(item);
}
// 基线管理
const productBasics = [];
for (let i = 0; i < 12; i++) {
  productBasics.push({
    id: faker.random.uuid(),
    title: `你的温柔带我流浪${i}`,
    status: faker.random.number(1),
    priority: faker.random.number(10),
    level: faker.random.number(2),
    tags: 'PER',
    module: faker.random.number(1),
    createTime: Date.now(),
    createUser: `创建人${i}`
  });
}
// 权限管理
const productLimit = {
  need: {
    control: 0,
    list: [{
      needLevel: 0,
      tags: 0,
      module: 0,
      createUser: 0,
      reviewUser: 0,
      releaseUser: 0,
      editLimit: 0,
      viewLimit: 0
    }]
  },
  test: {
    control: 1,
    list: [{
      testLevel: 1,
      tags: 1,
      module: 1,
      createUser: 1,
      reviewUser: 1,
      releaseUser: 1,
      actionUser: 1,
      editLimit: 1,
      viewLimit: 1
    }]
  },
  risk: {
    control: 1,
    list: [{
      createUser: 2,
      reviewUser: 2,
      releaseUser: 2,
      editLimit: 2,
      viewLimit: 2
    }]
  },
  defect: {
    control: 1,
    ccbSwitch: 1,
    ccbCharge: '110000'
  }
};

// 产品追溯
const productTrace = [{
  id: '3001',
  icon: 'SR',
  title: '一级 1',
  children: [{
    id: '3001',
    icon: 'SR',
    title: '二级 1-1',
    caseValue: 2,
    caseList: [{
      name: '测试用例2',
      value: 2
    }],
    children: [{
      id: '3001',
      icon: 'SR',
      title: '三级 1-1-1'
    }]
  }]
}, {
  id: '3001',
  icon: 'SR',
  title: '一级 2',
  children: [{
    id: '3001',
    icon: 'SR',
    title: '二级 2-1',
    children: [{
      id: '3001',
      icon: 'SR',
      title: '三级 2-1-1'
    }]
  }, {
    id: '3001',
    icon: 'SR',
    title: '二级 2-2',
    active: true,
    caseValue: 1,
    caseList: [{
      name: '测试用例1',
      value: 1
    }],
    children: [{
      id: '3001',
      icon: 'SR',
      title: '三级 2-2-1'
    }]
  }]
}, {
  id: '3001',
  icon: 'SR',
  title: '一级 3',
  active: true,
  children: [{
    id: '3001',
    icon: 'SR',
    title: '二级 3-1',
    children: [{
      id: '3001',
      icon: 'SR',
      title: '三级 3-1-1',
      caseValue: 4,
      caseList: [{
        name: '测试用例4',
        value: 4
      }],
    }]
  }, {
    id: '3001',
    icon: 'SR',
    title: '二级 3-2',
    children: [{
      id: '3001',
      icon: 'SR',
      title: '三级 3-2-1'
    }]
  }]
}];

// 产品风险管理
const riskDegree = ['可忽略', '严重', '中等', '灾难性'];
const riskProb = ['极少', '非常少', '很少', '偶尔', '有时', '经常'];
const riskRisk = [
  { name: '经常', value: 'F' },
  { name: '有时', value: 'E' },
  { name: '偶尔', value: 'D' },
  { name: '很少', value: 'C' },
  { name: '非常少', value: 'B' },
  { name: '极少', value: 'A' }
];
const riskLevelList = [];
for (let i = 0; i < 4; i++) {
  riskLevelList.push({
    id: faker.random.uuid(),
    value: faker.random.number(2),
    degree: riskDegree[i],
    definition: 'xyz',
  });
}
const riskProbList = [];
for (let i = 0; i < 6; i++) {
  riskProbList.push({
    id: faker.random.uuid(),
    value: faker.random.number(2),
    prob: riskProb[i],
    definition: 'xyz',
  });
}
const riskRiskList = [];
for (let i = 0; i < 6; i++) {
  riskRiskList.push({
    id: faker.random.uuid(),
    name: riskRisk[i].name,
    value: riskRisk[i].value,
    level0: faker.random.number(5),
    level1: faker.random.number(5),
    level2: faker.random.number(5),
    level3: faker.random.number(5)
  });
}

export default {
  productSelect,
  statusSelect,
  riskStatusSelect,
  levelSelect,
  moduleSelect,
  creatorSelect,
  treeData,
  needList,
  testList,
  defectList,
  riskList,
  columnList,
  productList,
  productDetail,
  productLevels,
  productStatus,
  productBasics,
  productLimit,
  productTrace,
  riskLevelList,
  riskProbList,
  riskRiskList
};
